import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.Map;
import java.util.List;
import java.util.HashMap;
import java.util.LinkedList;

import org.junit.Test;


public class GraphSearchTest {

	@Test(timeout = 300)
	public void testSearchABCQueue(){
		GraphSearch gs = new GraphSearch();
		
		Map<String, List<String>> map = new HashMap<String, List<String>>();
		
		List<String> adjA = new LinkedList<String>(Arrays.asList("B"));
		List<String> adjB = new LinkedList<String>(Arrays.asList("A", "C"));
		List<String> adjC = new LinkedList<String>(Arrays.asList("B"));
		List<String> adjD = new LinkedList<String>();
		
		map.put("A", adjA);
		map.put("B", adjB);
		map.put("C", adjC);
		map.put("D", adjD);
		
		boolean aToC = gs.search("A", new StructureQueue<String>(), map, "C");
		boolean bToC = gs.search("B", new StructureQueue<String>(), map, "C");
		boolean cToA = gs.search("C", new StructureQueue<String>(), map, "A");
		boolean nullStart = gs.search(null, new StructureQueue<String>(), map, "C");
		boolean nullEnd = gs.search("B", new StructureQueue<String>(), map, null);
		
		boolean aToD = gs.search("A", new StructureQueue<String>(), map, "D");
		
		assertEquals(aToC, true);
		assertEquals(bToC, true);
		assertEquals(cToA, true);
		assertEquals(nullStart, false);
		assertEquals(nullEnd, false);
		assertEquals(aToD, false);
		
	}
	
	@Test (timeout = 300)
	public void testSearchABCStack(){
		GraphSearch gs = new GraphSearch();
		
		Map<String, List<String>> map = new HashMap<String, List<String>>();
		
		List<String> adjA = new LinkedList<String>(Arrays.asList("B"));
		List<String> adjB = new LinkedList<String>(Arrays.asList("A", "C"));
		List<String> adjC = new LinkedList<String>(Arrays.asList("B"));
		
		map.put("A", adjA);
		map.put("B", adjB);
		map.put("C", adjC);
		
		boolean aToC = gs.search("A", new StructureStack<String>(), map, "C");
		boolean bToC = gs.search("B", new StructureStack<String>(), map, "C");
		boolean cToA = gs.search("C", new StructureStack<String>(), map, "A");
		boolean nullStart = gs.search(null, new StructureStack<String>(), map, "C");
		boolean nullEnd = gs.search("B", new StructureStack<String>(), map, null);
		
		boolean aToD = gs.search("A", new StructureQueue<String>(), map, "D");
		
		assertEquals(aToC, true);
		assertEquals(bToC, true);
		assertEquals(cToA, true);
		assertEquals(nullStart, false);
		assertEquals(nullEnd, false);
		assertEquals(aToD, false);
		
	}

}
